<!DOCTYPE html>
<html>
  <head>
      <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
      <title><?php echo isset($title) ? $title : '';?></title>
      <!-- 设置缩放 -->
      <meta name="viewport" content="minimal-ui,width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0" />
      <!-- IOS中禁用将数字识别为电话号码/忽略Android平台中对邮箱地址的识别 -->
      <meta name="format-detection" content="telephone=no" />
      <!-- windows phone 点击无高光 -->
      <meta name="msapplication-tap-highlight" content="no" />
      <!-- icon -->
      <link rel="shortcut icon" href="<?php echo ADMIN_ICO_PIC;?>" type="image/x-icon"/>
      <!-- css -->
      <link rel="stylesheet" type="text/css" href="<?php echo SYS_LINK;?>admin/css/content.css?v=<?php echo V_CSSJS;?>" />

      <style>
        body .sys_con{width:auto;min-width:auto;}
        body .sys_con_box{width:auto;min-width:auto;}
        body .sys_box{overflow:hidden;min-height:600px;}
        .left{float:left;width:500px;}
        .db_backups,.db_recovery{float:left;width:460px;min-height:850px;margin-bottom:20px;border-right:1px solid #ddd;}
        .title{height:30px;line-height:30px;text-align:center;font-size:16px;font-weight:400;}
        .tableNo{padding:5px;}
        .tableB{padding:5px 5px 5px 80px;}
        .ids{display:inline-block;width:30px;}
        input[type="checkbox"]{margin-right:10px;}
        .tablecon{display:inline-block;}
        #db_file{width:275px;border:1px solid #ccc;height:30px;}
        #tableAll{color:#07b9d4;font-weight:700;}
        .sub_btn {padding: 6px 15px;background: #00BCD4;color: #fff;margin-right: 98px;margin-top: 5px;}
      </style>
  </head>
<body class="noselect">
<?php
$userLevel = isset($userLevel) ? $userLevel : 0;
$powerInfo = isset($powerInfo) ? $powerInfo : powerInfoListDeVal();
?>
<div class="con_box">
    <!-- tab导航 -->
    <?php include SYS_PATH.SYS_APP_PATH.'/admin/views/admin_system/navtab.php';?>
	<!--  -->
	<div class="sys_con_box">
		<div class="sys_box ">
			<div class="db_backups">
				<div class="title">数据库备份</div>
				<?php
				if(!empty($result)){
				?>
				<div class="tableNo">
					<label id="tableAll">
						<span class="ids span_title" >全选</span>
						<input type="checkbox"  value="1" name="tableNo" id="tableNos" />
					</label>
					<span class="tablecon"></span>
					<input type="button" value="确认备份" class="sub_btn" id="backup_btn">
				</div>
				<?php 
                    if($result){
                        foreach($result as $k=>$v){
                            echo '
                            <div class="tableNo">
                                <span class="ids span_title">'.($k+1).'</span>
                                <input type="checkbox" class="checkbox_table" value="'.$v.'" name="tableNo[]" />
                                '.$v.'
                            </div>';
                        }
                    }
				}else{
					echo '数据表已丢失！';
				}
				?>
			</div>
			<div class="db_recovery">
				<div class="title">数据库还原</div>
				<div class="tableB">
					<select name="db_file" id="db_file">
						<option value="">请选择要恢复的数据</option>
						<?php
							if(!empty($sqlFile)){
								foreach($sqlFile as $v){
									echo '<option value="'.$v.'">'.$v.'</option>';
								}
							}
						?>
					</select>
					<input type="button" value="本地下载" class="sub_btn" id="download_btn">
                    <input type="button" value="数据还原" class="sub_btn" id="restore_btn">
				</div>
			</div>
		
		</div>
	</div>
</div>


</body>
<script language="javascript">
    var cssjsv = '<?php echo V_CSSJS;?>';
    var http_url = '<?php echo SYS_HOST;?>';
    var http_link = '<?php echo SYS_LINK;?>';
    var http_fix = '<?php echo SYS_URL_FIX;?>';
</script>
<script type="text/javascript" src="<?php echo SYS_LINK;?>admin/js/jquery.min.js?v=<?php echo V_CSSJS;?>"></script>
<script type="text/javascript" src="<?php echo SYS_LINK;?>admin/js/skin.js?v=<?php echo V_CSSJS;?>"></script>
<script type="text/javascript" src="<?php echo SYS_LINK;?>admin/js/common.js?v=<?php echo V_CSSJS;?>"></script>
<script type="text/javascript">file_load('info');</script>
<script language="javascript">
    // 页面加载完毕
    window.onload = function () {

    }
    // jquery
    $(function(){
        // 全选
        $('#tableAll').on('click',function(){
            if ($('#tableNos').attr('checked')) {
                $('.checkbox_table').attr('checked','checked');
            }else{
                $('.checkbox_table').removeAttr('checked');
            }
        })
        // 备份
        $('#backup_btn').on('click',function(){
            var tables = '';
            $(".checkbox_table:checkbox:checked").each(function(e){
                tables += $(this).val()+'-';
            });
            if(!tables){
                layer.msg('请先选中表');return false;
            }
            tables = tables.substring(0, tables.lastIndexOf('-'));
            if(tables.length <= 0){
                layer.msg('请选择要备份的数据表');return false;
            }
            window.location.href="<?php echo SYS_HOST.'admin_system_backupdb';?>/tables/"+tables+"<?php echo SYS_URL_FIX;?>";
        })

        // 还原
        $('#restore_btn').on('click',function(){
            var filedb = $('#db_file').val();
            if(filedb != '' && filedb != null){
                window.location.href="<?php echo SYS_HOST.'admin_system_restoredb';?>/filedb/"+filedb+"<?php echo SYS_URL_FIX;?>";
            }else{
                layer.msg('请选择要还原的sql文件');
            }
        })

        // 下载
        $('#download_btn').on('click',function(){
            var filedb = $('#db_file').val();
            if(filedb != '' && filedb != null){
                window.open("<?php echo SYS_HOST.str_replace(SYS_PATH, '', SYS_DB_PATH);?>"+filedb);
            }else{
                layer.msg('请选择要下载的sql文件');
            }
        })
    })
</script>
</html>